

<div class="wrapper">
        
        <div class="c">
            <table>
            <tr>
                <td align="right">
                    <a href="" id="synch_email" class="action" order="{{ order_name }}">Синхронизировать ящики</a>
                    <div id="load_icon_synch_email" order="{{ order_name }}" style="display:none">
                        Синхронизация ящиков <img alt="загрузка" src="{{ asset('bundles/billing/i/load.gif') }}">
                    </div>
                    <div id="load_icon_synch_error" order="{{ order_name }}">
                    </div>
                </td>
            </tr>
            </table>
        </div>
        
        <div id="domain_list" order="{{ order_name }}"> 
        {% for key, domain in emails_domains %}
            <div id="domain_item" order="{{ order_name }}" domain="{{ domain['domain'] }}"> 
                <hr>
                <h2 class="ml">Домен <span>{{ domain['domain'] }}</span></h2>
                <h5>IMAP/POP3: mail.{{ domain['domain'] }}</h5>
                <h5>SMTP: mail.{{ domain['domain'] }}</h5>

                <form id="email_form" order="{{ order_name }}" domain="{{ domain['domain'] }}">
                <div id="add_email_content" order="{{ order_name }}" domain="{{ domain['domain'] }}" style="display:none">
                    
                        <table>
                        <tr>
                            <td width="1" align="right">
                                Адрес:<input type="text" name="email_user" order="{{ order_name }}" domain="{{ domain['domain'] }}"/>@{{ domain['domain'] }}
                            </td>
                            <td class="status"></td>
                        </tr>
                        <tr>
                            <td width="1" align="right">
                                <a href="" id="generate_email_password" order="{{ order_name }}" domain="{{ domain['domain'] }}">сгенерировать</a>
                                Пароль:<input type="text" name="email_password" order="{{ order_name }}" domain="{{ domain['domain'] }}" />
                            </td>
                            <td class="status"></td>
                            <div id="load_icon_generate_email_password" order="{{ order_name }}" domain="{{ domain['domain'] }}" style="display:none">
                                Генерация пароля <img alt="загрузка" src="{{ asset('bundles/billing/i/load.gif') }}">
                            </div>
                        </tr>
                        <tr>
                            <td>
                                <a href="" id="add_email" order="{{ order_name }}" domain="{{ domain['domain'] }}">создать ящик</a>
                            </td>
                        </tr>
                        </table> 
                    
                </div>
                </form>
                <a href="" id="add_email_link" class="action" order="{{ order_name }}" domain="{{ domain['domain'] }}">Добавить ящик</a>

                <div id="load_icon_create_email" order="{{ order_name }}" domain="{{ domain['domain'] }}" style="display:none">
                    Отправление запроса <img alt="загрузка" src="{{ asset('bundles/billing/i/load.gif') }}">
                </div>
                
                <table class="mysql-detals">
                    <tr>
                        <td width="180">
                                <div class="mysql-item">Ящики:<br></div>
                        </td>
                        <td>
                            <div id="email_list" order="{{ order_name }}" domain="{{ domain['domain'] }}">
                            
                                {% for email in domain['emails'] %}
                                    {% if email.getIsActive %}
                                        {% include "BillingBundle:Orders_shared:user_index_active_email_template.html.twig" %}
                                    {% else %}
                                        {% include "BillingBundle:Orders_shared:user_index_not_active_email_template.html.twig" %}
                                    {% endif %}
                                {% endfor %}
                            
                            </div>
                           
                        </td>
                    </tr>
                </table>
                <br>
            </div>
            <script type="text/javascript">
            var validator = $('#email_form[order="{{ order_name }}"][domain="{{ domain['domain'] }}"]').validate({
                    rules: {
                            email_user: {
                                    required: true,
                                    maxlength: 64,
                                    check_email_login: true
                            },
                            email_password: {
                                    required: true,
                                    maxlength: 64,
                                    minlength: 5,
                                    check_password: true
                            }
                    },
                    messages: {
                            email_user: {
                                    required: "Введите название",
                                    maxlength: jQuery.format("Не более {0} символов")
                            },
                            email_password: {
                                    required: "Введите пароль",
                                    maxlength: jQuery.format("Не более {0} символов"),
                                    minlength: jQuery.format("Не менее {0} символов")
                            }
                    },

                    errorPlacement: function(error, element) {
                            error.appendTo( element.parent().next() );
                    },
                    success: function(label) {
                            // set &nbsp; as text for IE
                            label.html("&nbsp;").addClass("checked");
                    }
            });
            
            </script>
            
        {% endfor %}
        </div>
</div>

